#pragma once
#include"RBtree.h"

template<class K,class V>
class Mymap
{
	struct mapKofT
	{
		const K& operator()(const pair<K,V>& kv)
		{
			return kv.first;
		}
	};

public:

	using iterator = typename RBTree<K, pair<K, V>, mapKofT>::Iterator;

	iterator begin()
	{
		return _t.Begin();
	}

	iterator end()
	{
		return _t.End();
	}

	pair<iterator,bool> Insert(const pair<K, V>& kv)
	{
		return _t.Insert(kv);
	}

	V& operator[](const K key)
	{
		pair<iterator, bool>ret = Insert({ key,V() });
		return ret->second;
	}

private:
	RBTree<K, pair<K,V> , mapKofT> _t;
};
